import { getDetailInfo } from "../../utils/api";

export default {
  namespaced: true,
  state() {
    return {
      detailInfo: [],
    }
  },
  mutations: {
    getDetail(state, { result }) {
      if(state.detailInfo) {
        state.detailInfo = [...state.detailInfo, result];
      }else {
        state.detailInfo = [result];
      }
      state.detailInfo = [...new Set(state.detailInfo)]
      console.log(state.detailInfo);
    },
    delInfo(state) {
      state.detailInfo = [];
    }
  },
  actions: {
    async getDetail({ commit }, id) {
      const res = await getDetailInfo({ id: id });
      commit("getDetail", res);
    }
  },
}